// Package sysin
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.11
package sysin

import (
	"context"
	"hotgo/internal/model/entity"
	"hotgo/internal/model/input/form"

	"github.com/gogf/gf/v2/encoding/gjson"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/os/gtime"
)

// DistributionDetailUpdateFields 修改分销记录详情字段过滤
type DistributionDetailUpdateFields struct {
	TraceId      string  `json:"traceId"    dc:"记录 id"`
	Mid          int64   `json:"mid"        dc:"主记录 id"`
	MemberId     int64   `json:"memberId"   dc:"分销至用户"`
	ProductId    int64   `json:"productId"  dc:"商品 id"`
	CreditsLogId int64   `json:"creditsLogId" dc:"变动记录ID"`
	Amount       float64 `json:"amount"     dc:"分销金额"`
	Proportion   int     `json:"proportion" dc:"分销比例"`
	Type         int     `json:"type" dc:"类型"`
}

// DistributionDetailInsertFields 新增分销记录详情字段过滤
type DistributionDetailInsertFields struct {
	TraceId      string  `json:"traceId"    dc:"记录 id"`
	Mid          int64   `json:"mid"        dc:"主记录 id"`
	MemberId     int64   `json:"memberId"   dc:"分销至用户"`
	ProductId    int64   `json:"productId"  dc:"商品 id"`
	CreditsLogId int64   `json:"creditsLogId" dc:"变动记录ID"`
	Amount       float64 `json:"amount"     dc:"分销金额"`
	Proportion   int     `json:"proportion" dc:"分销比例"`
	Type         int     `json:"type" dc:"类型"`
}

// DistributionDetailEditInp 修改/新增分销记录详情
type DistributionDetailEditInp struct {
	entity.DistributionDetail
}

func (in *DistributionDetailEditInp) Filter(ctx context.Context) (err error) {
	// 验证记录 id
	if err := g.Validator().Rules("required").Data(in.TraceId).Messages("记录 id不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证主记录 id
	if err := g.Validator().Rules("required").Data(in.Mid).Messages("主记录 id不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证分销至用户
	if err := g.Validator().Rules("required").Data(in.MemberId).Messages("分销至用户不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证商品 id
	if err := g.Validator().Rules("required").Data(in.ProductId).Messages("商品 id不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证资金记录 id
	if err := g.Validator().Rules("required").Data(in.CreditsLogId).Messages("资金记录 id不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	return
}

type DistributionDetailEditModel struct{}

// DistributionDetailDeleteInp 删除分销记录详情
type DistributionDetailDeleteInp struct {
	Id interface{} `json:"id" v:"required#id不能为空" dc:"id"`
}

func (in *DistributionDetailDeleteInp) Filter(ctx context.Context) (err error) {
	return
}

type DistributionDetailDeleteModel struct{}

// DistributionDetailViewInp 获取指定分销记录详情信息
type DistributionDetailViewInp struct {
	Id int64 `json:"id" v:"required#id不能为空" dc:"id"`
}

func (in *DistributionDetailViewInp) Filter(ctx context.Context) (err error) {
	return
}

type DistributionDetailViewModel struct {
	entity.DistributionDetail
}

// DistributionDetailListInp 获取分销记录详情列表
type DistributionDetailListInp struct {
	form.PageReq
	Id                  int64         `json:"id"                  dc:"id"`
	TraceId             string        `json:"traceId"             dc:"记录 id"`
	CreatedAt           []*gtime.Time `json:"createdAt"           dc:"分销时间"`
	AdminMemberRoleId   int64         `json:"adminMemberRoleId"   dc:"角色ID"`
	AdminMemberMobile   string        `json:"adminMemberMobile"   dc:"手机号码"`
	AdminMemberNickname string        `json:"adminMemberNickname" dc:"微信昵称"`
	Type                int           `json:"type" dc:"类型"`
}

func (in *DistributionDetailListInp) Filter(ctx context.Context) (err error) {
	return
}

type DistributionDetailListModel struct {
	Id                   int64       `json:"id"                   dc:"id"`
	TraceId              string      `json:"traceId"              dc:"记录 id"`
	Mid                  int64       `json:"mid"                  dc:"主记录 id"`
	MemberId             int64       `json:"memberId"             dc:"分销至用户"`
	ProductId            int64       `json:"productId"            dc:"商品 id"`
	CreditsLogId         int64       `json:"creditsLogId"         dc:"资金记录 id"`
	Amount               float64     `json:"amount"               dc:"分销金额"`
	Proportion           int         `json:"proportion"           dc:"分销比例"`
	CreatedAt            *gtime.Time `json:"createdAt"            dc:"分销时间"`
	Type                 int         `json:"type"                 dc:"分销类型"`
	AdminMemberRoleId    int64       `json:"adminMemberRoleId"    dc:"角色ID"`
	AdminMemberMobile    string      `json:"adminMemberMobile"    dc:"手机号码"`
	AdminMemberNickname  string      `json:"adminMemberNickname"  dc:"微信昵称"`
	ProductName          string      `json:"productName"          dc:"商品名称"`
	ProductMainImage     string      `json:"productMainImage"     dc:""`
	ProductImages        *gjson.Json `json:"productImages"        dc:"商品配图"`
	ProductVipProportion int         `json:"productVipProportion" dc:"会员利润分配比例(%)"`
}

// DistributionDetailExportModel 导出分销记录详情
type DistributionDetailExportModel struct {
	Id                   int64       `json:"id"                   dc:"id"`
	TraceId              string      `json:"traceId"              dc:"记录 id"`
	Mid                  int64       `json:"mid"                  dc:"主记录 id"`
	MemberId             int64       `json:"memberId"             dc:"分销至用户"`
	ProductId            int64       `json:"productId"            dc:"商品 id"`
	CreditsLogId         int64       `json:"creditsLogId"         dc:"资金记录 id"`
	Amount               float64     `json:"amount"               dc:"分销金额"`
	Proportion           int         `json:"proportion"           dc:"分销比例"`
	CreatedAt            *gtime.Time `json:"createdAt"            dc:"分销时间"`
	Type                 int         `json:"type"                 dc:"分销类型"`
	AdminMemberRoleId    int64       `json:"adminMemberRoleId"    dc:"角色ID"`
	AdminMemberMobile    string      `json:"adminMemberMobile"    dc:"手机号码"`
	AdminMemberNickname  string      `json:"adminMemberNickname"  dc:"微信昵称"`
	ProductName          string      `json:"productName"          dc:"商品名称"`
	ProductVipProportion int         `json:"productVipProportion" dc:"会员利润分配比例(%)"`
}
